<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap4.2.1.min.css"/>
    <link rel="stylesheet" href="css/fontawesome.css">
    <link rel="stylesheet" href="css/templatemo-style.css">
    <link rel="stylesheet" href="css/owl.css">

    <%--    <link rel="stylesheet" href="css/reset.css">
        <link rel="stylesheet" href="css/car.css">--%>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
        // alert(md5("123456"));
        $(function () {
            //校验的是用户名是否存在
            $("#username").change(function () {
                //使用ajax 做username 的异步验证 checkUsername?username=xxxx
                $.get("usercheckname", "name=" + this.value, function (data) {
                    if (data.code == 1) {
                        $("#usernameMsg").html("用户名已经存在").css("color", "red");
                        $("#updateForm-submit").attr("disabled", true);
                        $("#updateForm-submit").html("不可修改").css("color", "red");
                    } else {
                        $("#usernameMsg").html("用户名可用").css("color", "green");
                        $("#updateForm-submit").removeAttr("disabled");
                        $("#updateForm-submit").html("确认修改").css("color", "#535ba0");
                    }
                })
            });
            //校验邮箱是否重复
            $("#email").change(function () {
                //使用ajax 做username 的异步验证 checkUsername?username=xxxx
                $.get("usercheckemail", "email=" + this.value, function (data) {
                    if (data.code == 1) {
                        $("#emailMsg").html("邮箱已经存在").css("color", "red");
                        $("#updateForm-submit").attr("disabled", true);
                        $("#updateForm-submit").html("不可修改").css("color", "red");
                    } else {
                        $("#emailMsg").html("邮箱可用").css("color", "green");
                        $("#updateForm-submit").removeAttr("disabled");
                        $("#updateForm-submit").html("确认修改").css("color", "#535ba0");
                    }
                })
            });
            //检验旧密码是否正确
            $("#passwordold").change(function () {
                $.get("usercheckpassword", "password=" + this.value + "&username=" + "${user.username}", function (data) {
                    if (data.code == 1) {
                        $("#helpBlockOld").html("旧密码正确").css("color", "green");
                        $("#updateForm-submit").removeAttr("disabled");
                        $("#updateForm-submit").html("确认修改").css("color", "#535ba0");
                    } else {
                        $("#helpBlockOld").html("旧密码错误").css("color", "red");
                        $("#updateForm-submit").attr("disabled", true);
                        $("#updateForm-submit").html("不可修改").css("color", "red");

                    }
                })

            })
        })

        function validate() {
            // alert("#password="+$("#password").val()+"#password1="+$("#password1").val())
            var p1 = $("#password").val();
            var p2 = $("#password1").val();
            var pold = $("#passwordold").val();
            if (p1 != "" && p2 != "" && pold != '') {
                if (p1 != p2) {
                    alert("您的两次新密码不一致");
                    return false;
                }
            } else {
                alert("您的新密码为空或者旧密码为空");
                return false;
            }
        }

        // console.log(validate())

    </script>
</head>
<body class="is-preload">

<!-- Wrapper -->
<div id="wrapper" class="">

    <!-- Main -->
    <div id="main">
        <div class="inner">

            <!-- Header -->
            <header id="header">
                <div class="logo">
                    <%--<a href="my.jsp">我的</a>--%>
                </div>
            </header>

            <!-- Banner -->
            <section class="forms">
                <div class="container-fluid">
                    <div>
                        <section class="contact-form">
                            <div class="container-fluid">
                                <div class="row">
                                    <div class="col-md-12">
                                        <h3>我的个人中心</h3>
                                        <hr>
                                        <form target="_parent" id="contact" action="updateUserinfo" method="post"
                                              onsubmit="return validate()">
                                            <div class="row">
                                                <div class="col-md-12">
                                                    <fieldset>
                                                        <span>用户名：</span><span class="help-block "
                                                                               id="usernameMsg"></span><input
                                                            type="hidden" name="id" value="${user.id}">
                                                        <input class="form-control" id="username" type="text"
                                                               name="username" value="${user.username}"/>
                                                        <%--                                                        <input name="name" type="text" class="form-control" id="name" placeholder="Your name..." required="">--%>
                                                    </fieldset>
                                                </div>
                                                <div class="col-md-12">
                                                    <fieldset>
                                                        <span>旧密码：</span><span id="helpBlockOld" class="help-block ">请输入您的旧密码</span>
                                                        <input class="form-control" id="passwordold" type="password"
                                                               name="passwordold" value="" placeholder="旧密码"/>
                                                        <%--                                                        <input name="email" type="text" class="form-control" id="email" placeholder="Your email..." required="">--%>
                                                    </fieldset>
                                                </div>
                                                <div class="col-md-12">
                                                    <fieldset>
                                                        <span>新密码：</span><span id="helpBlock" class="help-block ">请输入您的新密码</span>
                                                        <input class="form-control" id="password" type="password"
                                                               name="password" value="" placeholder="新密码"/>
                                                        <%--                                                        <input name="email" type="text" class="form-control" id="email" placeholder="Your email..." required="">--%>
                                                    </fieldset>
                                                </div>
                                                <div class="col-md-12">
                                                    <fieldset>
                                                        <span>新密码：</span><span id="helpBlock" class="help-block ">请再次输入您的新密码</span>
                                                        <input class="form-control" id="password1" type="password"
                                                               name="password1" value="" placeholder="新密码"/>
                                                        <%--                                                        <input name="email" type="text" class="form-control" id="email" placeholder="Your email..." required="">--%>
                                                    </fieldset>
                                                </div>
                                                <div class="col-md-12">
                                                    <fieldset>
                                                        <span>邮箱：</span><span id="emailMsg"
                                                                              class="help-block ">填写正确邮箱格式</span>
                                                        <input class="form-control" id="email" type="text" name="email"
                                                               value="${user.email}"/>
                                                        <%--<input name="email" type="text" class="form-control" id="email" placeholder="Your email..." required="">--%>
                                                    </fieldset>
                                                </div>

                                                <%--<div class="col-md-12 col-sm-12">
                                                    <div class="circle-item">

                                                    </div>
                                                </div>--%>

                                                <c:if test="${user.gender=='男'}">
                                                    <div class="col-md-6 col-sm-12">
                                                        <span>性别：</span>
                                                        <div class="circle-item">
                                                            <input name="gender" type="radio" id="sex-male" value="男"
                                                                   checked>
                                                            <label for="sex-male">男</label>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6 col-sm-12">
                                                        <span>&nbsp;</span>
                                                        <div class="circle-item">
                                                            <input name="gender" type="radio" id="sex-female" value="女">
                                                            <label for="sex-female">女</label>
                                                        </div>
                                                    </div>
                                                </c:if>
                                                <c:if test="${user.gender=='女'}">
                                                    <div class="col-md-6 col-sm-12">
                                                        <span>性别：</span>
                                                        <div class="circle-item">
                                                            <input name="gender" type="radio" id="sex-male" value="男">
                                                            <label for="sex-male">男</label>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6 col-sm-12">
                                                        <span>&nbsp;</span>
                                                        <div class="circle-item">
                                                            <input name="gender" type="radio" id="sex-female" value="女"
                                                                   checked>
                                                            <label for="sex-female">女</label>
                                                        </div>
                                                    </div>
                                                </c:if>

                                                <div class="col-md-12">
                                                    <span>&nbsp;</span>
                                                    <fieldset>
                                                        <button type="submit" id="updateForm-submit" class="button">
                                                            确认修改
                                                        </button>
                                                    </fieldset>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <%--<div class="col-md-6">
                                        <div id="map">


                                            &lt;%&ndash;<iframe src="" width="100%" height="420px" frameborder="0" style="border:0" allowfullscreen></iframe>&ndash;%&gt;
                                        </div>
                                    </div>--%>
                                </div>
                            </div>
                        </section>
                    </div>
                </div>
            </section>


        </div>
    </div>

    <!-- Sidebar -->
    <div id="sidebar">

        <div class="inner">


            <!-- Menu -->
            <nav id="menu">
                <ul>
                    <p style="font-size:18px">个人中心</p>
                    <li><a href="myList_info.jsp">我的个人中心</a></li>
                    <li><a href="">消息通知</a></li>
                    <li><a href="userAddressShow">收货地址</a></li>
                    <li><a href="https://www.google.com">优惠券</a></li>
                    <p style="font-size:18px">订单中心</p>
                    <li><a href="getOrderList">我的订单</a></li>
                    <li><a href="">意外保</a></li>
                    <li><a href="">团购订单</a></li>
                    <li><a href="">评价晒单</a></li>
                </ul>
            </nav>


        </div>
    </div>

</div>

</body>
<script src="js/jquery.min3.3.1.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>

<script src="js/browser.min.js"></script>
<script src="js/breakpoints.min.js"></script>
<script src="js/transition.js"></script>
<script src="js/owl-carousel.js"></script>
<script src="js/custom.js"></script>

</html>